<include file="Remark:header"/>
<div class="wraper">
    <div class="top other">
        <p><a href="javascript:history.back();" class="iconfont icon-zuo fl-left"></a>杭州生活品质总点评</p>
    </div>
    <div class="detail-title">{BEESCRM:$i} {BEESCRM:$data['info']['title']}</div>
    <div class="detail-list">
        <img src="{BEESCRM:$data['info']['picture']}"/>
        <p>{BEESCRM:$data['info']['description']}</p>
    </div>
    <div class="moudle">
        <a href="{BEESCRM::U('activity/remark/figure',array('act_id'=>$act_id,'title'=>$data['info']['title'],'i'=>$i,'type'=>1,'pid'=>$data['info']['id'],'wechat_id'=>$wechat_id))}">年度人物<span class="iconfont icon-you fl-right"></span></a>
        <volist name="data['type1']" id="vo">
        <p>{BEESCRM:$vo.title}</p>
        </volist>
    </div>
    <div class="moudle">
        <a href="{BEESCRM::U('activity/remark/figure',array('act_id'=>$act_id,'title'=>$data['info']['title'],'i'=>$i,'type'=>2,'pid'=>$data['info']['id'],'wechat_id'=>$wechat_id))}">年度区块<span class="iconfont icon-you fl-right"></span></a>
        <volist name="data['type2']" id="vo">
        <p>{BEESCRM:$vo.title}</p>
        </volist>
    </div>
    <div class="moudle">
        <a href="{BEESCRM::U('activity/remark/figure',array('act_id'=>$act_id,'title'=>$data['info']['title'],'i'=>$i,'type'=>3,'pid'=>$data['info']['id'],'wechat_id'=>$wechat_id))}">年度活动<span class="iconfont icon-you fl-right"></span></a>
        <volist name="data['type3']" id="vo">
        <p>{BEESCRM:$vo.title}</p>
        </volist>
    </div>
    
    <div class="conment clearfix marginb-50">
        <div class="title">专家点评（{BEESCRM:$commentSum}）</div>
        <div id="commentList">
        	<volist name="comment" id="vo">
        		<div class="list">
		            <div class="list-top clearfix">
		                <img class="fl-left" src="{BEESCRM:$vo.headimgurl}"/>
		                <span class="fl-left">{BEESCRM:$vo.nickname}</span>
		                <span class="time fl-right">{BEESCRM:$vo.create_time|date='Y-m-d',###}</span>
		            </div>
		            <p><switch name="vo.type">
					        <case value="2">#人物#</case>
					        <case value="3">#区块#</case>
					        <case value="4">#活动#</case>
					        <case value="1">#现象#</case>
					        <default/>#其他#
					    </switch>{BEESCRM:$vo.content}</p>
		        </div>
        	</volist>
        </div>
        <a href="javascript:void(0)" class="more" id="allComment">查看全部</a>
    </div>
    
    <div class="btn-box">
        <a href="#" class="btn" id="conment">点评</a>
        <a href="#" class="btn" id="recommend">举荐</a>
    </div>
    <div class="popbox"></div>
    <div class="pop-main" id="conment-box">
        <p class="pop-title">专家点评</p>
        <span class="iconfont icon-guanbi guanbi"></span>
        <div class="object clearfix">
            <p>选择你的点评对象</p>
            <div class="object-box" id="commentOption">
                <span class="check"  data-type="1">现象</span>
                <span  data-type="2">人物</span>
                <span  data-type="3">区块</span>
                <span  data-type="4">活动</span>
            </div>
        </div>
        <div class="contain">
            <textarea placeholder="写下你的评语#现象#" id="content"></textarea>
        </div>
        <a href="#" class="btn green-btn" id="confirm-commment">确认提交</a>
    </div>
    <div class="pop-main" id="recommend-box">
        <p class="pop-title">举荐</p>
        <span class="iconfont icon-guanbi guanbi"></span>
        <div class="object clearfix">
            <p>选择你的举荐对象</p>
            <div class="object-box clearfix" id="p-check">
                <span class="check" data-type="1">现象</span>
                <span data-type="2">人物</span>
                <span data-type="3">区块</span>
                <span data-type="4">活动</span>
            </div>
        </div>
        <div class="contain">
            <p>举荐对象</p>
            <input type="text" id="title" value=" "/>
            <p>举荐理由</p>
            <input type="text" id="reason" value=""/>
            <p>您的姓名</p>
            <input type="text" id="username" value=" "/>
            <p>您的联系电话</p>
            <input type="tel" id="mobile" value=""/>
        </div>
        <a href="#" class="btn green-btn" id="recSub">确认提交</a>
    </div>
</div>
<script src="/assets/activity/remark/js/jquery-2.1.0.min.js"></script>
<script>
    $(function(){
        $(window).load(function(){
            $('.pop-box1').hide();
        });
        $('.object-box').on('click','span',function(){
            $(this).addClass('check').siblings().removeClass('check');
        });
        $('#conment').click(function(){
            $('.popbox').show();
            $('#conment-box').addClass('up');
        });
        $('#recommend').click(function(){
            $('.popbox').show();
            $('#recommend-box').addClass('up');
        });
        $('.guanbi').click(function(){
            $('.popbox').fadeOut(500);
            $('#conment-box').removeClass('up');
            $('#recommend-box').removeClass('up');
        });
    });
    $('#allComment').click(function(){
    	var limit = 'all';
    	$.ajax({
    		'url':"{BEESCRM::U('/Activity/Remark/commentMore',array('wechat_id'=>$wechat_id,'act_id'=>$act_id))}",
    		'type':'post',
    		'data':{'limit':limit,'act_id':{BEESCRM:$act_id},'pid':{BEESCRM:$pid} },
    		beforeSend:function(){
    			 $('.pop-box1').show();
    		},
    		 success:function(data){
    			 $('.pop-box1').hide();
    			 var json = $.parseJSON(data);
    			 if(json.status == 'S'){
    				 $('#commentList').html(json.html);
    				 $('#allComment').remove();
                     //infotips(json.message,$('.submit_tips'),'right');
                 }else{
                     infotips(json.message,$('.submit_tips'));
                 }
    		},
    		error:function(){
    			$('.pop-box1').hide();
    			infotips('获取失败',$('.submit_tips'));
    		},
    	})
    });
    $(document).on('click','#confirm-commment',function(){
    	var type = $('#commentOption').children('.check').data('type');
    	if(!type){
    		infotips('请选择点评对象',$('.submit_tips'));
    	}
        var comment = $('#content').val();
        comment = comment.replace(/^\s+|\s+$/g,"");
        if(!comment){
            infotips('评论内容不能为空',$('.submit_tips'));
            return false;
        }
        $.ajax({
            type:'post',
            dataType:'json',
            data:{'content':comment,'type':type,'act_id':{BEESCRM:$act_id},'pid':{BEESCRM:$pid}},
            url:"{BEESCRM::U('/Activity/Remark/addComment',array('wechat_id'=>$wechat_id,'act_id'=>$act_id))}",
            success:function(data){
                if(data.status == 'S'){
                    console.log(data);
                    infotips('评论成功',$('.submit_tips'),'right');
                   // $('#comment-list').append(data.html);
                    $('#comment').val('');
                    $('.popbox').hide();
                    $('#conment-box').removeClass('up');
                    window.location.reload();
                }else{
                    infotips('评论失败，请稍后再试',$('.submit_tips'));
                }
            },
            error:function(){
                infotips('评论失败，请稍后再试',$('.submit_tips'));
            },
        });
    });
    $('#recSub').on('click',function(){
    	var type=$('#p-check').children('.check').data('type');
    	var title=$('#title').val();
    	var reason=$('#reason').val();
    	var username=$('#username').val();
    	var mobile=$('#mobile').val();
    	if(!title){
    		infotips('举荐对象不能为空',$('.submit_tips'));
    	}else if(!reason){
    		infotips('举荐理由不能为空',$('.submit_tips'));
    	}else if(!username){
    		infotips('用户名不能为空',$('.submit_tips'));
    	}else if(!/^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/i.test(mobile)){ 
    		infotips('手机有误',$('.submit_tips'));
    	}else{
    		$.ajax({
                type:'post',
                dataType:'json',
                data:{'type':type,'title':title,'reason':reason,'username':username,'mobile':mobile},
                url:"{BEESCRM::U('/Activity/Remark/addRecommend',array('act_id'=>$act_id,'wechat_id'=>$wechat_id))}",
                success:function(data){
                    if(data.status == 'S'){
                        infotips('举荐成功',$('.submit_tips'),'right');
                        setTimeout('window.location.reload()',3000);
                    }else{
                        infotips('举荐失败，请稍后再试',$('.submit_tips'));
                    }
                },
                error:function(){
                    infotips('评论失败，请稍后再试',$('.submit_tips'));
                },
            });
    	}
    });
</script>
</body>

</html>
